<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="/common/user.jsp"%>
<%@ include file="/common/operatehistory.jsp"%>
<%!
	// 展示赞或踩详情
	String showLove(Input input) {
		Message msg = new Message(0);
		Integer id = input.getInt("id");
		Integer type = input.getInt("type", LOVE);
		Integer page = 1;
		Integer itemCount = input.getInt("item_count", 20);
		String sinceID = input.getDesc("since_id","0"); // 下拉刷新 传oid
		String maxID = input.getDesc("max_id","0"); // 上拉加载 传oid
		String order = "desc"; // 排序
		Where where = new Where();
		if (!sinceID.equals("0") && !sinceID.equals("")) {
			where.and("oh.id > " + sinceID);
			order = "asc";
		} else if (!maxID.equals("0") && !maxID.equals("")) {
			where.and("oh.id < " + maxID);
		}
		List<Map> list = QBuilder.db("basedb").select("new map(oh.id as oid, case when u.nickName is null then u.userName else u.nickName end as user_name,u.name as name, u.avatar  as avatar, u.id as id, u.type as type, u.gender as gender, concat(from_unixtime(oh.cTime/1000, '%Y-%m-%d %H:%i:%s'), '') as create_time)").from("OperateHistory as oh, User as u").where(where.and("oh.oid=", id).and("oh.category=", QUEST_CATEGORY).and("oh.status=", STATUS_ENABLE).and("oh.uid=u.id").and("oh.operate=", type)).order("oh.id", order).page(itemCount, page).query().getResultObj();
		for (Map map:list) {
			User user = userByUid((Integer)map.get("id"));
			map.put("avatar", getDefaultAvatar(user));
			map.put("user_name", getDisplayName(user));
			map.put("role", Tools.getDesc(user.getJson("role"), "1"));		}
		msg.put("data", list);
		return msg.toJson();
	}
%>
<%
	Tools.encryptPrint(out, showLove(input));
%>
